package com.puppet.building182.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.puppet.building182.pojo.Log;
import com.puppet.building182.pojo.Result;
import com.puppet.building182.pojo.enums.BuildingCode;
import com.puppet.building182.service.LogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/log")
public class LogController {
@Autowired
    private LogService logService;

@GetMapping("/{pageNum}/{pageSize}")
    public Result<?> getLog(@PathVariable("pageNum") Integer pageNum, @PathVariable("pageSize") Integer pageSize) {
    PageHelper.startPage(pageNum, pageSize);
    List<Log> list = logService.getLog();
    PageInfo<Log> pageInfo = new PageInfo<Log>(list);
    return Result.ok(pageInfo);
}
@DeleteMapping("/{id}")
    public Result<?> deleteLog(@PathVariable("id") Integer id) {
    return Result.ok(logService.deleteLog(id), BuildingCode.DELETE_SUCCESS.getMessage());
}
@GetMapping("/getLogById/{id}")
    public Result<?> getLogById(@PathVariable("id") Integer id) {
    return Result.ok(logService.getLogById(id));
}
@GetMapping("/style")
    public Result<?> getStyle() {
    return Result.ok(logService.getStyle());
}
}
